import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15

Window {
    id:wind
    visible: true
    height: 600
    width: 800
    opacity: 1
    color: "red"

    property int oldheight: 600
    property int oldwidth: 800

    onHeightChanged: {
        console.debug("window高度改变为:" + height)
    }
    onWidthChanged: {
        console.debug("window宽度改变为:" + width)
    }

    //标题栏
    Rectangle{
        id:titlebar
        height: 30

        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right

        //解决最大化之后窗口内容出去屏幕
        anchors.topMargin: wind.visibility == 4 ? 8 : 0
        anchors.leftMargin: wind.visibility == 4 ? 8 : 0
        anchors.rightMargin: wind.visibility == 4 ? 8 : 0

        opacity: 1

        color: "#666666"
        Text {
            text: qsTr("标题栏")
            color:  "white"
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter
        }
    }


    Item{
        opacity: 1
        anchors.top: titlebar.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        width: 100
        height: 100
        //解决最大化之后窗口内容出去屏幕
        anchors.bottomMargin : wind.visibility == 4 ? 8 : 0
        anchors.leftMargin: wind.visibility == 4 ? 8 : 0
        anchors.rightMargin: wind.visibility == 4 ? 8 : 0
        Rectangle{
            anchors.fill: parent
            color: "lightgray"
        }
        Button{
            onClicked: {
                wind.close()
            }
            text: "exit"
        }

    }
}
